package org.example.javawebday1.mapper;


import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.example.javawebday1.pojo.Emp;
import org.example.javawebday1.pojo.EmpExpr;
import org.example.javawebday1.pojo.EmpQueryForm;
import org.example.javawebday1.pojo.LoginInfo;

import java.util.List;

@Mapper
public interface EmpMapper {

    @Select("select count(*) from emp left join dept on emp.dept_id=dept.id")
    Long getTotal();

//    @Select("select emp.*,dept.name as deptName from emp left join dept on emp.dept_id=dept.id order by emp.update_time desc limit #{index},#{pageSize}")
//    List<Emp> getEmps(Integer index, Integer pageSize);

//    @Select("select emp.*,dept.name as deptName from emp left join dept on emp.dept_id=dept.id order by emp.update_time desc")
//    List<Emp> getEmps(EmpQueryForm empQueryForm);

    List<Emp> getEmps(EmpQueryForm empQueryForm);


    void addEmp(Emp emp);

    void addEmpExprs(Emp emp);
    
    void deleteEmps(Integer[] ids);

    void deleteEmpExprs(Integer[] ids);

    @Select("select * from emp where id=#{id} ")
    Emp getEmpById(Integer id);

    @Select("select * from emp_expr where emp_id=#{empId}")
    List<EmpExpr> getEmpExprByEmpId(Integer empId);

    @Select("select * from emp where username =#{username} and password = #{password};")
    Emp getEmpByNameAndPassword(String username, String password);

    void updateEmp(Emp emp);
}

